﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

namespace BSC
{
    public partial class _Default : System.Web.UI.Page
    {
        
        void LoadWindow(string id, string title, string cls,Ext.Net.Menu parent,Ext.Net.Icon? icon)
        {
            DesktopModule dskM = new DesktopModule();
            dskM.ModuleID = "mod"+id;
            dskM.WindowID = "win"+id;
            dskM.AutoRun = false;
            
            //mnuDanhMuc.Items.Add(dskM.Launcher);
            if (parent != null)
            {
                Ext.Net.MenuItem m = new Ext.Net.MenuItem();
                m.Icon=icon.Value;
                m.ID = id + "Launcher";
                m.Text = title;
                m.Listeners.Click.Handler = "#{" + dskM.WindowID + "}.show()";
                parent.Items.Add(m);
                //parent.Menu.Add(dskM.Launcher.
            }
            else
            {
                dskM.Launcher.ID = id + "Launcher";
                dskM.Launcher.Text = title;
                dskM.Launcher.Icon = Icon.CoinsAdd;
            }
            DesktopShortcut dskS = new DesktopShortcut();
            dskS.ModuleID = "mod"+id;
            dskS.Text = title;
            dskS.IconCls = "shortcut-icon icon-"+cls;
            
            MyDesktop.Modules.Add(dskM);
            MyDesktop.Shortcuts.Add(dskS);
            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Global.GlobalVariable.User == null)
            {
                Response.Redirect("login.aspx");
            }
            this.ResourceManager1.Theme = ThemeControl.Theme;
            LoadWindow("CostImport","Nhập chi phí","cost-import",null,null);
            LoadWindow("RevImport", "Nhập doanh thu", "rev-import",null,null);
            LoadWindow("Report", "Báo cáo", "report",null,null);
            //LoadWindow("DonVi", "Đơn vị", "donvi", mnuDanhMuc,Ext.Net.Icon.ApplicationForm);
            //LoadWindow("DichVu", "Dịch vụ", "dichvu", mnuDanhMuc, Ext.Net.Icon.ApplicationForm);
        }
    }
}
